package com.example.springbootbookv2.controller;

import com.example.springbootbookv2.model.User;
import com.example.springbootbookv2.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户控制层
 * @author waqwb
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/test")
    public String test(Model model){
        List<User> userList = userService.findAll();
        model.addAttribute("users",userList);
        return "user";
    }

    @RequestMapping("/index")
    public String index(){
        return "index";
    }

}
